import HttpRequest from "@/utils/request";
import { IDictTypeRows, IDictType, IDictDataRows, IDictData } from "./type";

// 查询列表
export function getDictTypes(params = {}) {
  return HttpRequest<IDictTypeRows>("/dictType", "GET", params, {
    isLoading: true,
  });
}
// 查询所有
export function getAllDictType() {
  return HttpRequest<IDictTypeRows>("/dictType/findAll", "GET");
}

// 查询某个
export function getDictType(id: number) {
  return HttpRequest<IDictType>("/dictType/" + id, "GET");
}

// 新增
export function addDictType(params = {}) {
  return HttpRequest("/dictType", "POST", params);
}

// 修改
export function updateDictType(params: any) {
  return HttpRequest("/dictType", "PUT", params);
}

// 删除
export function delDictType(ids: number[] = []) {
  return HttpRequest("/dictType", "DELETE", { ids: ids.join() });
}

// 查询列表
export function getDictDatas(params = {}) {
  return HttpRequest<IDictDataRows>("/dictData", "GET", params, {
    isLoading: true,
  });
}

// 查询某个
export function getDictData(id: number) {
  return HttpRequest<IDictData>("/dictData/" + id, "GET");
}

// 通过类型查询某个
export function getDictDataByType(type: string) {
  return HttpRequest<IDictDataRows>("/dictData/findByType/" + type, "GET");
}

// 新增
export function addDictData(params = {}) {
  return HttpRequest("/dictData", "POST", params);
}

// 修改
export function updateDictData(params: any) {
  return HttpRequest("/dictData", "PUT", params);
}

// 删除
export function delDictData(ids: number[] = []) {
  return HttpRequest("/dictData", "DELETE", { ids: ids.join() });
}
